// 请注意，下方代码是我对ZHY_MARIO的代码的改正与简化，并非完全由我原创，
// 感谢原作者的代码帮助理解本题
// https://gitee.com/ZHY_MARIO/noj/blob/main/43%E3%80%90%E4%B8%93%E4%B8%9A%E8%9E%8D%E5%90%88%EF%BC%9A%E8%88%AA%E7%A9%BA%E3%80%91%E9%A3%9E%E6%9C%BA%E8%B5%B7%E9%A3%9E%E9%80%9F%E5%BA%A6/noj043.c#

#include <stdio.h>
#include <math.h>
int calculateSpeed(double temperature, double pressure, int elevation, int runway, int weight, int flaps, int wet) {
    // 检查输入是否在有效范围内
    if (flaps != 1 && flaps != 5 && flaps != 15) { return -1; }
    if (weight < 41413 || weight > 65000 || runway <= 6900) { return -1; }
    // 计算温度档和气压档
    int temperatureLevel = floor(temperature / 10);
    int pressureLevel = ceil((elevation + 1000.0 * (29.92 - pressure)) / 1000);
    // 检查操纵参考表是否存在
    if (temperatureLevel < 0 || temperatureLevel > 7 || pressureLevel < 0 || pressureLevel > 9) { return -1; }
    // 根据温度档和气压档查找操纵参考值并检查操纵参考表是否存在V1、Vr和V2
    int referenceLevel = 'A' + temperatureLevel * 10 + pressureLevel;
    printf("%d\n", referenceLevel);
    while (referenceLevel > 'Z') { referenceLevel -= 26; }
    printf("%d\n", referenceLevel);
    // 不是，这个破COLUMN REFERNCE怎么这么复杂，我完全没法理解怎么取数据
    if (referenceLevel > 'E') { return -1; }
    // 根据襟翼位置、起飞重量和操纵参考值查找V1、Vr和V2
    int speedTable[3][5] = {
        {117, 126, 134, 142, 151},
        {122, 131, 139, 147, 156},
        {127, 136, 145, 153, 162}
    };
    int speedIndex = (flaps - 1) / 7;
    int* speedRow = speedTable[speedIndex];
    int v1 = speedRow[weight / 13000];
    int vr = speedRow[weight / 13000] + 11;
    int v2 = speedRow[weight / 13000] + 18;
    // 如果是湿跑道，根据跑道长度和襟翼位置查找折扣值
    if (wet) {
        int discountTable[3][3] = {
            {0, 0, 0},
            {0, 0, 0},
            {0, 0, 0}
        };
        int discountIndex = (flaps - 1) / 7;
        int* discountRow = discountTable[discountIndex];
        int discount = discountRow[runway / 1000];
        v1 -= discount;
    }
    printf("V1=%dkts Vr=%dkts V2=%dkts\n", v1, vr, v2);
    return 0;
}
int main() {
    double temperature, pressure;
    int elevation, runway, weight, flaps, wet;
    scanf("%lf%lf", &temperature, &pressure);
    scanf("%d%d%d%d%d", &elevation, &runway, &weight, &flaps, &wet);
    int result = calculateSpeed(temperature, pressure, elevation, runway, weight, flaps, wet);
    if (result == -1) { printf("Flight not possible!"); }
    return 0;
}
